import os
import re
import requests
from retrying import retry
from selenium import webdriver

# tmplist = filter(lambda n: n % 2 == 1, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
# newlist = list(tmplist)
# print(tmplist)
# print(newlist)
#
#
# line='https://www.partzilla.com/catalog/kawasaki/motorcycle/1979/km100-a4/footrests-stand-brake-pedal'
#
# os.path.basename(line)
# matchObj = re.match( r'[^/]+(?!.*/)', line, re.M|re.I)


# headers = {"User-Agent":
#            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"}
#
# r = requests.get('https://www.partzilla.com', headers=headers)
#
# browser = webdriver.Chrome(executable_path="chromedriver.exe")
# browser.get('https://www.partzilla.com')
# print(browser.page_source)


num = 0


@retry(stop_max_attempt_number=20,wait_fixed=1000)
def test_stop_max_delay():
    try:
        browser = webdriver.Chrome(executable_path="chromedriver.exe")
        browser.get('https://flights.ctrip.com/itinerary/roundtrip/sha-sia?date=2019-07-03%2C2019-07-11')
        print(browser.page_source)
        # global num
        # num += 1
        # print(num)
        #
        # r = requests.get("https://list.tmall.com/search_product.htm?spm=a3204.7084713.1996500281.2.5ABxvb&user_id=725677994&cat=51462017&active=1&style=g&acm=lb-zebra-27092-331839.1003.4.457100&scm=1003.4.lb-zebra-27092-331839.OTHER_14434945970211_457100", timeout=1000)
        # print(r.status_code)
        # print(r.text)
    except requests.exceptions.RequestException as e:

        print('NET_STATUS is not good')
        raise e


test_stop_max_delay()
